<template>
  <div class="wrap">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
      <el-table-column label="全新名称" width="180">
        <template #default="xxx">
          <span>{{xxx.row.authName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="权限等级">
        <template #default="xxx">
          <el-tag
            align="center"
            type="success"
            v-if="xxx.row.level == '0'"
          >{{xxx.row.level |transform}}</el-tag>
          <el-tag
            align="center"
            type="error"
            v-if="xxx.row.level == '1'"
          >{{xxx.row.level |transform}}</el-tag>
          <el-tag
            align="center"
            type="warning"
            v-if="xxx.row.level == '2'"
          >{{xxx.row.level |transform}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="访问路径">
        <template #default="xxx">
          <span>{{xxx.row.path}}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { adminlist } from "@/api/admin.js";
export default {
  data() {
    return {
      tableData: []
    };
  },
  mounted() {
    adminlist({
      type: "list"
    }).then(res => {
      this.tableData = res.data.data;
    });
  },
  methods: {},
  filters: {
    transform: function(value) {
      if (value === "0") {
        return (value = "一级权限");
      }
      if (value === "1") {
        return (value = "二级权限");
      }
      if (value === "2") {
        return (value = "三级权限");
      }
    }
  }
};
</script>

<style scoped lang="scss">
.wrap {
  margin-top: 20px;
  .el-table {
    width: 95%;
    margin-top: 20px;
    margin: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  }
}
</style>